package com.ttx.springmvc.example2.controller;

import com.ttx.springmvc.example2.model.JsonModel;
import com.ttx.springmvc.example2.model.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

/**
 * 用于测试{@link com.ttx.springmvc.example2.config}
 * @author TimFruit
 * @date 19-7-28 下午5:48
 */
@Api(value = "/config", tags="配置测试模块")

@Controller
@RequestMapping("/config")
public class ConfigController {


    @ApiOperation(value = "/getJsonModel", notes = "测试fastjson配置")
    @RequestMapping(value = "/getJsonModel", method = RequestMethod.GET
    )
    @ResponseBody
    public JsonModel getJsonModel(){
        JsonModel model=new JsonModel();
        model.setUsername("timfruit");
        model.setAge(11);
        model.setBirthday(new Date());

        return model;
    }


    @ApiOperation(value = "/login", notes = "用户登录,用于测试拦截器配置")
    @GetMapping("/login")
    @ResponseBody
    public User login(){
        User user=new User();
        user.setUsername("timfruit");
        user.setAge(11);

        return user;
    }

}
